package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {
  /**
   * 根据菜品id或者套餐id查询购物车
   * @return
   */
  public List<ShoppingCart> list(ShoppingCart shoppingCart);

  /**
   * 修改购物车表
   * @param shoppingCart
   */
  public void update(ShoppingCart shoppingCart);

  /**
   * 添加购物车
   * @param shoppingCart
   */
  public void add(ShoppingCart shoppingCart);

  /**
   * 根据userId查询购物车列表
   * @param userId
   * @return
   */
  @Select("select * from shopping_cart where user_id = #{userId}")
  List<ShoppingCart> getListByUserId(Long userId);

  /**
   * 清空购物车
   * @param userId
   */
  @Delete("delete from shopping_cart where user_id = #{userId}")
  void clear(Long userId);
}
